package com.aaa.dao;

import com.aaa.pojo.Fund_Management;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface Fund_Management_Mapper {
    @Select("select * FROM fund_management m,growth_rate r,investment_horizon h,fund_type t WHERE m.g_id=r.g_id and m.h_id=h.h_id and m.type_id=t.type_id")
    List<Fund_Management> selectAll();
    @Insert("insert into fund_management(f_amount,g_id,h_id,type_id)values(#{f_amount},#{g_id},#{h_id},#{type_id})")
    boolean insert(Fund_Management management);
    @Update("UPDATE fund_type f,growth_rate r , fund_management m,investment_horizon h SET \n" +
            "type_code=#{type_code},type_abbreviate=#{type_abbreviate},type_name=#{type_name},g_day=#{g_day},g_month=#{g_month},g_year=#{g_year},f_amount=#{f_amount},h_day=#{h_day},h_deadline=#{h_deadline} \n" +
            "WHERE f_id=#{f_id} and  m.g_id= r.g_id and m.h_id = h.h_id and m.type_id = f.type_id")
    boolean update(Fund_Management management);
    @Delete("DELETE FROM fund_management where f_id=#{f_id}")
    boolean delete(Integer f_id);
    @Select("select * FROM fund_management m,growth_rate r,investment_horizon h,fund_type t WHERE m.g_id=r.g_id and m.h_id=h.h_id and m.type_id=t.type_id and f_id=#{f_id}")
    Fund_Management selectById(Integer f_id);
}
